-- || Created by Unlimited

Userpanel = {
	keyToOpen = "U",
	keyState = "down",
	tab = 1,
	btnSize = 1,
	apps = {
		[1] = "Accountinformationen",
		[2] = "Modifikationen",
		[3] = "Serverinformationen"
	},
	visible = false,
	tabElements = {
		[1] = {},
		[2] = {},
		[3] = {}
	}
}

function Userpanel:show()
	
	Userpanel.tabElements[1].tab = dx:createButton(524, 363, 290, 33, Userpanel.apps[1], false, Userpanel.btnSize, 'default-bold', 0, 0, 0, 168, true, true, function() Userpanel:setTab(1) end)
	Userpanel.tabElements[2].tab = dx:createButton(815, 363, 290, 33, Userpanel.apps[2], false, Userpanel.btnSize, 'default-bold', 0, 0, 0, 168, true, true, function() Userpanel:setTab(2) end)
	Userpanel.tabElements[3].tab = dx:createButton(1105, 363, 290, 33, Userpanel.apps[3], false, Userpanel.btnSize, 'default-bold', 0, 0, 0, 168, true, true, function() Userpanel:setTab(3) end)
end

--dx:createButton(x, y, w, h, text, pg, size, font, c1, c2, c3, a, click, hover, func, ...)

function Userpanel:setTab(tab)
	Userpanel.tab = tab
	Userpanel:onTabChange()
end

function Userpanel:render()
	if Userpanel.visible then
		dxDrawRectangle(524, 362, 871, 356, tocolor(0, 0, 0, 185), false)
		dxDrawLine(524, 396, 1397, 396, tocolor(255, 0, 0, 255), 2, false)
		dxDrawLine(815, 363, 814, 396, tocolor(255, 0, 0, 255), 2, false)
		dxDrawLine(1105, 363, 1104, 396, tocolor(255, 0, 0, 255), 2, false)
		dxDrawLine(524, 396, 1397, 396, tocolor(255, 0, 0, 255), 2, false)
		dxDrawLine(815, 363, 814, 396, tocolor(255, 0, 0, 255), 2, false)
		dxDrawLine(1105, 363, 1104, 396, tocolor(255, 0, 0, 255), 2, false)
		
		if Userpanel.tab == 1 then
			dxDrawText(Userpanel.apps[Userpanel.tab], 526, 403, 1389, 714, tocolor(255, 255, 255, 255), 5.00, "default", "center", "center", false, false, false, false, false)
		elseif Userpanel.tab == 2 then
			dxDrawText(Userpanel.apps[Userpanel.tab], 526, 403, 1389, 714, tocolor(255, 255, 255, 255), 5.00, "default", "center", "center", false, false, false, false, false)
		elseif Userpanel.tab == 3 then
			dxDrawText(Userpanel.apps[Userpanel.tab], 526, 403, 1389, 714, tocolor(255, 255, 255, 255), 5.00, "default", "center", "center", false, false, false, false, false)
		else
			return
		end
	end
end
addEventHandler("onClientRender", root, Userpanel.render)

function Userpanel:onTabChange()
	if Userpanel.tab == 1 then
	
	elseif Userpanel.tab == 2 then
	
	elseif Userpanel.tab == 3 then
	
	else
		return true
	end
end

bindKey(Userpanel.keyToOpen, Userpanel.keyState, function()
	Userpanel.visible = not Userpanel.visible
	showCursor(Userpanel.visible)
	if Userpanel.visible == false then
		Userpanel:destroyAll()
	else
		Userpanel:show()
	end
end)

function Userpanel:destroyAll()
	for index, value in pairs ( Userpanel.tabElements ) do
		for key, value in pairs ( Userpanel.tabElements[index] ) do
			dx:RemoveButton(value)
			if isElement(value) then
				destroyElement(value)
				Userpanel.tabElements[index][key] = nil
			end
		end
	end
end